package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.SecKillRequest;
import one.stand.response.SecKillResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Hongcj
 * @CreateDate: 2019/7/19 10:40
 * @Description:
 */
@RestController
@RequestMapping("crmPc/secKill")
@Api(tags="秒杀管理")
public class SecKillController extends BaseController {

    @PostMapping("/selectKillGoodsList")
    @ApiOperation(value = "秒杀列表")
    @ApiImplicitParam(name = "draftType",value = "0: 草稿箱 1：正式发布",required = true,dataType = "Integer")
    @ApiController(isLogin = true,company = true,card = true,paramClass = SecKillRequest.class )
    public ResultModel<List<SecKillResponse>> selectKillGoodsList(@RequestAttribute SecKillRequest request) {
        return crmFegin.selectKillGoodsList(request);
    }

    @PostMapping("/addKillGoodsInfo")
    @ApiOperation(value = "添加/修改秒杀商品配置")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "killId",value = "秒杀Id",required = true,dataType = "Integer"),
            @ApiImplicitParam(name = "draftType",value = "0: 草稿箱 1：正式发布",required = true,dataType = "Integer"),
            @ApiImplicitParam(name = "goodsId",value = "商品id",required = true,dataType = "Integer"),
            @ApiImplicitParam(name = "startTime",value = "开始时间",required = true,dataType = "Date"),
            @ApiImplicitParam(name = "endTime",value = "结束时间",required = true,dataType = "Date"),
            @ApiImplicitParam(name = "killType",value = "1：限时秒杀  2：促销秒杀",required = true,dataType = "Integer"),
            @ApiImplicitParam(name = "maxPurchase",value = "单账号最多可购买数",required = true,dataType = "Integer"),
            @ApiImplicitParam(name = "updateType", value = "是否为草稿箱修改 0：否 1：是", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "goodSpecRequestList", value = "商品规格拼团金额和拼团库存", required = true, paramType = "list"),
    })
    @ApiController(isLogin = true,company = true,card = true,paramClass = SecKillRequest.class )
    public ResultModel<Boolean> addKillGoodsInfo(@RequestAttribute SecKillRequest request) {
        return crmFegin.addKillGoodsInfo(request);
    }

    @PostMapping("/delKillGoodsInfo")
    @ApiOperation(value = "删除秒杀商品配置")
    @ApiImplicitParam(name = "killId",value = "秒杀ID",required = true,dataType = "Integer")
    @ApiController(isLogin = true,company = true,card = true,paramClass = SecKillRequest.class )
    public ResultModel<Boolean> delKillGoodsInfo(@RequestAttribute SecKillRequest request){
        return crmFegin.delKillGoodsInfo(request);
    }

    @PostMapping("updateKillGoodsInfo")
    @ApiOperation(value = "秒杀列表编辑")
    @ApiImplicitParam(name = "killId", value = "秒杀id", required = true, paramType = "Integer")
    @ApiController(isLogin = true, company = true, card = true, paramClass = SecKillRequest.class)
    public ResultModel<SecKillResponse> updateGoodsAssembleInfo(@RequestAttribute SecKillRequest request){
        return crmFegin.updateKillGoodsInfo(request);
    }

    @PostMapping("releaseKillGoods")
    @ApiOperation(value = "发布秒杀商品")
    @ApiImplicitParam(name = "killId", value = "秒杀id", required = true, paramType = "Integer")
    @ApiController(isLogin = true, company = true, card = true, paramClass = SecKillRequest.class)
    public ResultModel<Boolean> releaseKillGoods(@RequestAttribute SecKillRequest request){
        return crmFegin.releaseKillGoods(request);
    }
}
